package cn.wh.aop.framework;

import cn.wh.aop.AdvisedSupport;

/**
 * @Description 代理工厂
 * @Version 1.0.0
 * @Date 2022/11/22 10:30
 * @Created wh
 */
public class ProxyFactory {

    private AdvisedSupport advisedSupport;

    public ProxyFactory(AdvisedSupport advisedSupport) {
        this.advisedSupport = advisedSupport;
    }

    public Object getProxy(){
        return createAopProxy().getProxy();
    }

    private AopProxy  createAopProxy(){
        if (advisedSupport.isProxyTargetClass()){
            return new Cglib2AopProxy(advisedSupport);
        }
        return new JdkDynamicAopProxy(advisedSupport);
    }

}
